package com.czx.controller;

import com.czx.common.utils.R;
import com.czx.entity.MyPage;
import com.czx.service.DiscussPostService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
public class postController {
    @Autowired
    private DiscussPostService dps;

    @RequestMapping("/post")
    public String getIndex(MyPage page, Model model,Integer id,Integer orderMode) {

        page =dps.getPostId(page,id,orderMode);
        model.addAttribute("page", page);
        page.setPath("/post");
        return "site/post";
    }
    @RequestMapping("/top")
    @ResponseBody
    public R top(@RequestParam("id") Integer postId, @RequestParam("type") Integer postType){
        System.out.println(postType+"1111111111111111111111111111");
        System.out.println(postId+"3333333333333333333333333333");
        dps.top(postId,postType);
        return R.success("置顶成功");
    }
    @RequestMapping("/wonderful")
    @ResponseBody
    public R wonderful(@RequestParam("id") Integer postId){

        System.out.println(postId+"3333333333333333333333333333");
        dps.wonderful(postId);
        return R.success("加精");
    }
    @RequestMapping("/delete")
    @ResponseBody
    public R delete(@RequestParam("id") Integer postId){
        dps.delete(postId);
        return R.success("加精");
    }
}
